#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=1000000, mods=998244353;

long long qpower(long long a, int n) {
  long long s=1;
  for (; n>1; n/=2) {
    if (n%2) {
      s = s*a%mods;
    }
    a = a*a%mods;
  }
  return s*a%mods;
}

int main() {
  freopen("temple.in", "r", stdin);
  freopen("temple.out", "w", stdout);

  static long long fact[2*maxn+1], unfact[2*maxn+1];

  fact[0] = 1;
  for (int i=1; i<=2*maxn; i++) {
    fact[i] = fact[i-1]*i%mods;
  }
  unfact[2*maxn] = qpower(fact[2*maxn], mods-2);
  for (int i=2*maxn; i>0; i--) {
    unfact[i-1] = unfact[i]*i%mods;
  }

  int t;
  scanf("%d", &t);
  for (int i=1; i<=t; i++) {
    int n, m, u, v;
    scanf("%d %d", &n, &m);
    u = (n-m+1)/2+(n-m+1)%2, v=m;
    printf("%lld\n", fact[u+v-1]*unfact[v]%mods*unfact[u-1]%mods);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
